#include "parseur.h"
#include <stdio.h>
#include <stdlib.h>

int main(){

  char* mess=malloc(sizeof(char)*256);
  strcpy(mess,"announce listen 1024 seed [toto.dat 156 15656 45 dizze.lll 1564fd 456451 3] leech [1 9 2]");


  struct srv*s =malloc(sizeof(*s));
  struct hash_table*ht =init_table();

  struct client* C = creerClient("1.243.233.13", 10666); 
  struct client* C2 = creerClient("1.243.233.14", 10667);
 
  ajouter_client(ht,C);  
  ajouter_client(ht,C2);
  s->t=ht;
  s->c = C;
  s->sock=0;
  fprintf(stderr,"\nmess:%s\n",mess);
  annonce(mess,s);
  s->c=C2;
  strcpy(mess,"announce listen 1026 seed [toto.dat 56045 15656 45 trololo.c 5671564 56451 89] leech [3 4 8]");
  annonce(mess,s);
  //  printTable(ht);
  /*
  strcpy(mess,"look [filesize<15000 filesize>1]"); 
  fprintf(stderr,"\nmess:%s\n",mess);
  chercher(mess,s); 
  */
  /*
  printTable(ht);
  strcpy(mess,"getfile 45"); 
  fprintf(stderr,"\n%s\n",mess);
  demande(mess,s); */

  strcpy(mess,"update seed [45] leech [4564 4565 2222]"); 
  fprintf(stderr,"\nmess:%s\n",mess);
  miseAJour(mess,s); 
  printf("\n");
  printTable(ht);
  return EXIT_SUCCESS;
}
